var gulp = require('gulp')
var uglify = require('gulp-uglify')
var sass=require('gulp-sass')
var sourcemaps = require('gulp-sourcemaps')
var autoprefixer = require('gulp-autoprefixer')

gulp.task('minijs', function () {
    return gulp.src('./js/**/*.js')
      .pipe(uglify())
      .pipe(gulp.dest('./dist/js'))
  })

gulp.task('sass',function(){
    return gulp.src('./scss/*.scss')
    .pipe(sourcemaps.init())
    .pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError)) // 应用在如果自动监听sass转换，那么如果sass文件出错，不加这一行会直接跳出
    .pipe(sourcemaps.write()) // 转换后再写出map文件
    .pipe(autoprefixer({
      browsers: ['> 0%']
    }))
    .pipe(gulp.dest('./dist/css'))
})